// 查询当前用户的总公里数
async function getTotalKilometers(data){
    let selectSql = `SELECT * FROM totalkilometers WHERE userId = '${data[0].userId}'`;
    let selectRows = await global.sql(selectSql)
    if(selectRows.status) {
        return {
            code: 200,
            msg: '请求成功',
            data: selectRows.data
        }
    }
   
}

async function indexDataCount(data){
    let selectSql = `SELECT 'line' AS name, COUNT(*) AS total FROM line WHERE userId = '${data.userId}'
    UNION ALL
    SELECT 'video', COUNT(*) FROM video WHERE userId = '${data.userId}'
    UNION ALL
    SELECT 'imageData', COUNT(*) FROM imageData WHERE userId = '${data.userId}'
    UNION ALL
    SELECT 'participantsforactivity', COUNT(*) FROM participantsforactivity WHERE userId = '${data.userId}'`
    
    const countNum = await global.sql(selectSql)
    if (countNum.status) {
        const resData = {}
        countNum.data.map(item => {
            resData[item.name] = item.total
        })
        return {
            code: 200,
            msg: '请求成功',
            data: resData
        }
    }
   
}




exports.indexDataCount = indexDataCount
